package com.recommend.controller.admin;

import java.util.List;

import javax.annotation.Resource;

import com.recommend.domain.MovieDomain;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.recommend.dto.admin.RecommendDto;
import com.recommend.service.RecommendService;

/**
 * Created by lw.
 */
@RestController
@RequestMapping("/admin/recommend")
public class RecommendController {
    private final static Logger logger = LoggerFactory.getLogger(LoginController.class);

    @Resource
    private RecommendService recommendService;

    @RequestMapping(value = "/getAllRecommend", method = RequestMethod.POST)
    @ResponseBody
    public List<RecommendDto> getAllRecommend(){
        logger.info("==============================get all recommend============");
        return recommendService.getAllRecommend();
    }

    @RequestMapping(value = "/searchRecommend", method = RequestMethod.POST)
    @ResponseBody
    public List<RecommendDto> searchRecommend(RecommendDto recommendDto){
        logger.info("==============================get all recommend by customerName={}===========", recommendDto);
        return recommendService.getRecommendSelective(recommendDto);
    }

    @RequestMapping(value = "/searchRecommendMovie", method = RequestMethod.POST)
    @ResponseBody
    public List<MovieDomain> searchRecommendMovie(int customerId){
        logger.info("===========================search recommend movie={}===========", customerId);
        return recommendService.getRecommendByCustomerId(customerId);
    }
}
